import uiautomation
from page.index import IndexPage
class fapiaohaoshezhi():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()
        shujuwangge = his.DataGridControl(ClassName='DataGrid')
        shuju1=shujuwangge.DataItemControl(ClassName='DataGridRow', Name='Ksy.ChssClient.Access.Model.FPConfig')
        xiugai =  his.ButtonControl(ClassName='Button',Name='修改')
        menzhenfapiaohaoshezhichuangkou = his.WindowControl(ClassName='Window',Name='门诊发票号设置')
        liebiao = his.ListControl(AutomationId='lstChkGroup',ClassName='ListBox')
        baocun = menzhenfapiaohaoshezhichuangkou.ButtonControl(ClassName='Button',Name='保存')
        guanlianyaofang = shuju1.CustomControl(ClassName='DataGridCell',foundIndex=6)

        ap=IndexPage()
        #点击数据1
        def click_sj1(self):
                self.shuju1.Click()
        ##点击修改按钮
        def click_xg_btn(self):
                self.xiugai.Click()
        # #点击关联药房
        # def click_glyf(self,num):
        #         lst = self.liebiao.GetFirstChildControl()
        #         for i in range(num):
        #                 lst.Click()
        #                 lst = lst.GetNextSiblingControl()
        def click_glyf(self,*mc):
                glyfmc = self.guanlianyaofang.Name
                lst = self.liebiao.GetChildren()
                for i in lst:
                        if i.GetFirstChildControl().Name in glyfmc or i.GetFirstChildControl().Name not in mc:
                                print(i.GetFirstChildControl().Name)

                        else:
                                i.Click()
        # def click_glyf(self):
        #         glyfmc = self.guanlianyaofang.Name
        #
        #         lst = self.liebiao.GetFirstChildControl()
        #
        #         while True:
        #                 if lst.GetFirstChildControl().Name in glyfmc:
        #                         pass
        #                 else:
        #                         lst.Click()
        #                         lst = lst.GetNextSiblingControl()
        #                         if lst is None:
        #                                 break
        #点击保存按钮
        def click_bc_btn(self):
                self.baocun.Click()

        #发票号设置
        def fphsz(self,*mc):
                self.ap.jrym_no1("发票号设置")
                self.click_sj1()
                self.click_xg_btn()
                self.click_glyf(*mc)
                self.click_bc_btn()
